const Announcement = require('../models/Announcement')

const upsertAnnouncement = async geojson => {
  const [record, firstTime] = await Announcement.upsert({
    id: 1,
    geojson,
  })
  return [record.toJSON(), firstTime]
}

const getAnnouncement = async () => {
  const record = await Announcement.findOne({
    where: {
      id: 1,
    },
  })
  return record?.toJSON()
}

module.exports = { upsertAnnouncement, getAnnouncement }
